<script setup>
import ComAffix from "@/components/ComAffix.vue";
import {ref} from "vue";
import {getNoticeByFans} from "@/api/notice.js";
import {humanizeTime} from "@/utiles/format.js";

const fans = ref([])

const getFans = async () =>{
  const res = await getNoticeByFans()
  fans.value = res.data.data
  console.log(fans.value)
}

const follow = (id) => {

}

getFans()

</script>

<template>
  <div class="main">
    <el-affix :offset="0">
      <ComAffix></ComAffix>
    </el-affix>
    <div class="w">
      <div class="notice-nav">
        <span><router-link  :to="{ name: 'Notice' }">评论</router-link></span>
        <span><router-link  :to="{ name: 'NoticeLike' }">赞和收藏</router-link></span>
        <span><router-link  :to="{ name: 'NoticeFollow' }">新增关注</router-link></span>
      </div>

      <div class="notification-item">
        <el-card v-for="(fan,index) in fans" :key=index  class="notification-item">
          <div class="notification-header">
            <el-avatar :size="40" :src="fan.userAvatar"/>
            <div class="user-info">
              <span class="nickname">{{fan.userName }}</span>
              <span class="time">{{humanizeTime(fan.createTime)}}</span>
            </div>
          </div>
          <div>
            <span>开始关注你</span>
          </div>
          <div>
            <span @click="follow(fan.userId)">回关</span>
          </div>
        </el-card>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.w {
  width: 800px;
  margin: 0 auto;
}

.notice-nav {
  display: flex;
  align-items: center;
  margin: 30px 0;
  padding: 20px 20px;
  background: white;
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);

  span {
    margin-right: 30px;
    cursor: pointer;
    color: #666;
    padding: 8px 12px;
    border-radius: 4px;

    &.active {
      background: #f0f2f5;
      color: #409eff;
      font-weight: 500;
    }

    &:hover {
      background: #f5f7fa;
    }
  }
}


a {
  text-decoration: none;
  cursor: pointer;
  color: #636363;
}

.notification-item {
  margin-bottom: 16px;
  transition: all 0.3s;

  &:hover {
    transform: translateX(5px);
  }
}

.notification-header {
  display: flex;
  align-items: center;
  margin-bottom: 16px;

  .user-info {
    margin-left: 12px;

    .nickname {
      font-weight: 500;
      margin-right: 8px;
    }

    .time {
      color: #909399;
      font-size: 0.85em;
    }
  }
}


</style>
